<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['role']=$_SESSION['role'];
if($_RQ['op']=='main'){
	$member=cfc('core')->member_show($_SESSION['uid']);
	$mymember=pdo_get('jy_nongfee_member',array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	$member=array_merge($member,$mymember);
	$return['member']=$member;
	$return['list']=array();
	set_html('title','我的'.$this->db_title);
	exi($return);
}
if($_RQ['op']=='getlist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'type'=>array(7,8));
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_nongfee_feelog',$params,array($pindex,$psize),$total,$fields,'',$orderby);	
	foreach($return['list'] as &$v){
			$teampaixu=pdo_getcolumn('jy_nongfee_cang',array('id'=>$v['cangid'],'uniacid'=>$_SESSION['uniacid']),'paixu');
			$yaopaixu=pdo_getcolumn('jy_nongfee_yao',array('id'=>$v['yaoid'],'uniacid'=>$_SESSION['uniacid']),'paixu');
			$v['createtime']=date('Y-m-d H:m:s',$v['createtime']);
			$v['statustitle']=$this->canlog_status[$v['status']];
			$v['typetitle']=$this->feelog_type[$v['type']];
			$v['title']='第'.$teampaixu.'庄园第'.$yaopaixu.''.$this->y_title;
	}
	exi($return);
}
if($_RQ['op']=='post'){
	$member=pdo_get('jy_nongfee_member',array('mid'=>$_SESSION['uid']));
	$post=get_postdata();
	if(!$post['fee']){
		exi('请输入转账金额！','erroe');
	}
	if($member['baofee']<$post['fee']){
		exi('兑换额度不能大于，当前'.$this->db_title.'额度！','erroe');
	}
	model('core/member')->member_credit($_SESSION['uid'],'credit1',$post['fee'],true,'jy_nongfee',$this->db_title.'兑换');
	pdo_update('jy_nongfee_member',array('baofee -='=>$post['fee']),array('mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	exi('兑换成功！');
}